﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DevExpress.AgDataGrid;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:internal="clr-namespace:DevExpress.AgDataGrid.Internal;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:utils="clr-namespace:DevExpress.AgDataGrid.Utils;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">

    <Style TargetType="local:AgDataGrid">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGrid">
                    <Canvas x:Name="Surface">
                        <Canvas>
                            <Canvas.Clip>
                                <RectangleGeometry x:Name="GridMainClip" RadiusX="3" RadiusY="3"/>
                            </Canvas.Clip>
                            <Grid Name="RootElement">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="1" />
                                </Grid.ColumnDefinitions>
                                <Border Background="#FF6E6E6E" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="4" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                                <local:AgGroupStackPanel x:Name="GroupPanelPresenterElement" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="4" 
                                                         HorizontalAlignment="Left" Width="{TemplateBinding Width}" StretchChildren="True" EmptySize="40" Visibility="{TemplateBinding ShowGroupPanel}"/>
                                <Border x:Name="TopWhiteLine" HorizontalAlignment="Stretch" BorderBrush="#FFFFFFFF" BorderThickness="0,1,0,1" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" Height="1" Visibility="Visible"/>
                                <Border HorizontalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="2" Visibility="{TemplateBinding ShowColumnHeaders}">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                            <GradientStop Color="#FF6CA2DF"/>
                                            <GradientStop Color="#FF92BAE7" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                                <Border HorizontalAlignment="Stretch" BorderBrush="#FFFFFFFF" BorderThickness="0,1,0,1" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="3" Height="1" Visibility="{TemplateBinding ShowColumnHeaders}"/>
                                <internal:AgLineStackPanel x:Name="ColumnHeadersPresenterElement" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="4" RenderLastLine="False"
                                                           HorizontalAlignment="Left" Orientation="Horizontal" LinesWidth="{TemplateBinding VerticalLinesThickness}" ShowLines="{TemplateBinding ShowVerticalLines}" 
                                                           LinesFill="White" StretchChildren="True" LinesMargin="0" Visibility="{TemplateBinding ShowColumnHeaders}"/>
                                <Border Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4" HorizontalAlignment="Stretch" 
									    VerticalAlignment="Stretch" Background="#FF6E6E6E" IsHitTestVisible="False" Height="5" Visibility="{TemplateBinding ShowColumnHeaders}"/>
                                <Canvas x:Name="CellsClipperElement" Background="White" Grid.Column="1" Grid.Row="5">
                                    <!--<utils:StackVisibleIndexPanel x:Name="CellsPresenterElement" Orientation="Vertical" ArrangeAccordingToVisibleIndex="True" />-->
                                    <internal:AgLineStackPanel x:Name="CellsPresenterElement" Orientation="Vertical" ArrangeAccordingToVisibleIndex="True" 
														       LinesWidth="{TemplateBinding HorizontalLinesThickness}"
														       ShowLines="{TemplateBinding ShowHorizontalLines}" 
														       StretchLines="ByPreviousAndNextElements" />
                                </Canvas>

                                <ScrollBar x:Name="HorizontalScrollbarElement" Grid.Column="1" Grid.Row="6" Orientation="Horizontal" 
									       Height="17" local:dxElementStyles.StyleName="ScrollBarStyle" />
                                <Rectangle x:Name="BottomRightCornerElement" Grid.Column="2" Grid.Row="6" Height="17" Width="17">
                                    <Rectangle.Fill>
                                        <RadialGradientBrush GradientOrigin="0.17399999499321,0.180999994277954">
                                            <RadialGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.443" ScaleY="1.443"/>
                                                    <SkewTransform CenterX="0.5" CenterY="0.5"/>
                                                    <RotateTransform CenterX="0.5" CenterY="0.5"/>
                                                    <TranslateTransform X="0" Y="0"/>
                                                </TransformGroup>
                                            </RadialGradientBrush.RelativeTransform>
                                            <GradientStop Color="#FFDEDEDE"/>
                                            <GradientStop Color="#FFF0F0F0" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <ScrollBar x:Name="VerticalScrollbarElement" Grid.Column="2" Grid.Row="5" Grid.RowSpan="1" Orientation="Vertical" 
									       Width="17" local:dxElementStyles.StyleName="ScrollBarStyle" />

                                <Grid Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="5" Grid.RowSpan="2" HorizontalAlignment="Stretch" 
									    VerticalAlignment="Stretch" IsHitTestVisible="False">
                                    <Path x:Name="LeftBottomCorner" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 754,628L 754,629C 754,630.657 755.343,632 757,632L 758,632L 758,633L 753,633L 753,628L 754,628 Z " Height="5" Margin="0,0,0,-1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="5"/>
                                    <Path x:Name="RightBottomCorner" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 773,624L 773,625C 773,626.657 771.657,628 770,628L 769,628L 769,629L 774,629L 774,624L 773,624 Z " Height="5" Margin="0,0,0,-1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="5"/>
                                </Grid>
                                <Border Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="7" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF6E6E6E"/>
                                <internal:AgLineStackPanel x:Name="TotalPanelPresenterElement" Grid.Column="1" Grid.Row="7" HorizontalAlignment="Left" Orientation="Horizontal"  RenderLastLine="False"
													       LinesWidth="{TemplateBinding VerticalLinesThickness}" ShowLines="{TemplateBinding ShowVerticalLines}" LinesFill="White" LinesMargin="6" MinHeight="31" 
													       StretchChildren="True" Visibility="{TemplateBinding ShowTotals}"/>
                                <Rectangle x:Name="BottomBorder" Grid.ColumnSpan="4" Grid.Row="7" Fill="#FF6E6E6E" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="1" />
                                <Rectangle x:Name="LeftBorder" Grid.Column="0" Grid.Row="4" Grid.RowSpan="3" Fill="#FF6E6E6E" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="1" />
                                <Rectangle x:Name="RightBorder" Fill="#FF6E6E6E" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="1" 
									       Grid.Column="3" Grid.Row="4" Grid.RowSpan="3" />
                                <Grid x:Name="TopRoundCorners" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="5"  HorizontalAlignment="Stretch"
									    VerticalAlignment="Stretch" IsHitTestVisible="False" Visibility="Collapsed"
                                      RenderTransform="1,0,0,-1,0,0" RenderTransformOrigin="0.5,0.5">
                                    <Path x:Name="LeftTopCorner" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 754,628L 754,629C 754,630.657 755.343,632 757,632L 758,632L 758,633L 753,633L 753,628L 754,628 Z " Height="5" Margin="0,0,0,-1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="5"/>
                                    <Path x:Name="RightTopCorner" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 773,624L 773,625C 773,626.657 771.657,628 770,628L 769,628L 769,629L 774,629L 774,624L 773,624 Z " Height="5" Margin="0,0,0,-1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="5"/>
                                </Grid>
                                <Rectangle x:Name="TopBorder" Grid.ColumnSpan="4" Grid.Row="4" Fill="#FF6E6E6E" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="1" Visibility="Collapsed"/>
                            </Grid>
                        </Canvas>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="EmptyGroupPanelTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="Drag a column header here to group by that column" Foreground="White" Margin="15,14,0,13"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="CellStyle">
            <Setter.Value>
                <local:AgStyle>
                    <local:AgSetter Property="Foreground">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="Black" />
                        </local:AgSetter.Value>
                    </local:AgSetter>
                    <local:AgSetter Property="Background">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="Transparent"/>
                        </local:AgSetter.Value>
                    </local:AgSetter>
                </local:AgStyle>
            </Setter.Value>
        </Setter>
        <Setter Property="FocusedRowCellStyle">
            <Setter.Value>
                <local:AgStyle>
                    <local:AgSetter Property="Foreground">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="White" />
                        </local:AgSetter.Value>
                    </local:AgSetter>
                </local:AgStyle>
            </Setter.Value>
        </Setter>
        <Setter Property="FocusedCellStyle">
            <Setter.Value>
                <local:AgStyle>
                    <local:AgSetter Property="Foreground">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="Black" />
                        </local:AgSetter.Value>
                    </local:AgSetter>
                    <local:AgSetter Property="Background">
                        <local:AgSetter.Value>
                            <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                <GradientStop Color="#FFE0EAF7" Offset="0"/>
                                <GradientStop Color="#FFE9F3FD" Offset="1"/>
                            </LinearGradientBrush>
                        </local:AgSetter.Value>
                    </local:AgSetter>
                </local:AgStyle>
            </Setter.Value>
        </Setter>
        <Setter Property="EditingCellStyle">
            <Setter.Value>
                <local:AgStyle>
                    <local:AgSetter Property="Foreground">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="Black"/>
                        </local:AgSetter.Value>
                    </local:AgSetter>
                    <local:AgSetter Property="Background">
                        <local:AgSetter.Value>
                            <SolidColorBrush Color="White"/>
                        </local:AgSetter.Value>
                    </local:AgSetter>
                </local:AgStyle>
            </Setter.Value>
        </Setter>
        <Setter Property="DragArrowsTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Width="13">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.Triggers>
                            <EventTrigger RoutedEvent="Grid.Loaded">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard RepeatBehavior="Forever">
                                                <DoubleAnimation Storyboard.TargetName="Path3" Storyboard.TargetProperty="(Canvas.Top)" From="-11" To="-15" AutoReverse="True" Duration="00:00:00.75" />
                                                <DoubleAnimation Storyboard.TargetName="Path4" Storyboard.TargetProperty="(Canvas.Top)" From="-10" To="-14" AutoReverse="True" Duration="00:00:00.75" />
                                                <DoubleAnimation Storyboard.TargetName="Path1" Storyboard.TargetProperty="(Canvas.Top)" From="10" To="14" AutoReverse="True" Duration="00:00:00.75" />
                                                <DoubleAnimation Storyboard.TargetName="Path2" Storyboard.TargetProperty="(Canvas.Top)" From="11" To="15" AutoReverse="True" Duration="00:00:00.75" />
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </Grid.Triggers>
                        <Canvas x:Name="DownArrow" Width="13" Height="11" Grid.Row="0">
                            <Path x:Name="Path3" Width="13" Height="11" Canvas.Left="-6" Canvas.Top="0" Stretch="Fill" Fill="#FF000000" Data="F1 M 6,11L 7,11L 13,5L 12.9995,4L 10,4L 10,0L 3,0L 3,4L 0,4L 0,5L 6,11 Z "/>
                            <Path x:Name="Path4" Width="11" Height="9" Canvas.Left="-5" Canvas.Top="1" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M 6,10L 7,10L 12,5L 9,5L 9,1L 4,1L 4,5L 1,5L 6,10 Z "/>
                        </Canvas>
                        <Canvas x:Name="UpArrow" Width="13" Height="11" Grid.Row="2">
                            <Path x:Name="Path1" Width="13" Height="11" Canvas.Left="-6" Canvas.Top="0" Stretch="Fill" Fill="#FF000000" Data="F1 M 7,0L 6,0L 0,6L 0.000488281,7L 3,7L 3,11L 10,11L 10,7L 13,7L 13,6L 7,0 Z "/>
                            <Path x:Name="Path2" Width="11" Height="9" Canvas.Left="-5" Canvas.Top="1" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M 7,1L 6,1L 1,6L 4,6L 4,10L 9,10L 9,6L 12,6L 7,1 Z "/>
                        </Canvas>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="DataRowTemplate">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridRow">
                    <Grid Name="RootElement">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Grid.Resources>
                            <Storyboard x:Name="Preview Story">
                                <DoubleAnimation x:Name="Preview Animation" Duration="0:0:0.500" Storyboard.TargetName="PreviewPresenterElement" Storyboard.TargetProperty="Height" />
                            </Storyboard>
                        </Grid.Resources>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="RowStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="OddElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="NormalAlternative">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="OddElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" Duration="00:00:00" To="1"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="SelectedElement" Opacity="0" Grid.Row="0">
                            <Border.Background>
                                <SolidColorBrush Color="#FFDBE9F9" />
                            </Border.Background>
                        </Border>
                        <Border x:Name="OddElement" Opacity="0" Grid.Row="0">
                            <Border.Background>
                                <SolidColorBrush Color="#FFE9F0FD" />
                            </Border.Background>
                        </Border>
                        <Border x:Name="MouseOverElement" CornerRadius="0,0,0,0" Opacity="0" Grid.Row="0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#FFBEDAF9"/>
                                    <GradientStop Color="#FFD3E6FB" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="FocusedElement" CornerRadius="3,3,3,3" Opacity="0" Grid.Row="0" Margin="1,1,1,1">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#FF6DA2DE"/>
                                    <GradientStop Color="#FF91B9E6" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <internal:AgLineStackPanel x:Name="CellsPresenterElement" Orientation="Horizontal" Grid.Row="0" 
												   LinesWidth="{TemplateBinding VerticalLinesThickness}" ShowLines="{TemplateBinding ShowVerticalLines}" 
												   HorizontalAlignment="Left" StretchChildren="True" LinesFill="{TemplateBinding VerticalLinesBrush}"/>
                        <ContentControl x:Name="PreviewPresenterElement" Grid.Row="1" Height="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:AgDataGridColumnHeader">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridColumnHeader">
                    <Grid x:Name="RootElement" Cursor="Hand" >
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                <GradientStop Color="#FF6CA2DF"/>
                                <GradientStop Color="#FF92BAE7" Offset="1"/>
                            </LinearGradientBrush>
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.5" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.25" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="1" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="MouseOverElement" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#508acc" Offset="0"/>
                                    <GradientStop Color="#6ca0d9" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="PressedElement" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
								Opacity="0" Background="#FF585858" />

                        <ContentPresenter Content="{TemplateBinding Content}" Grid.Column="0" Margin="6,5,6,5" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        <Rectangle x:Name="Resizer" Opacity="0" Fill="AliceBlue" Width="5" Grid.Column="1" StrokeThickness="1" 
								   Cursor="SizeWE" HorizontalAlignment="Right" VerticalAlignment="Stretch" />

                        <Path x:Name="SortDescendent" Grid.Column="1" Stretch="Fill" Fill="White" Data="F1 M 678,521L 681,527L 682,527L 685,521L 678,521 Z " Height="6" HorizontalAlignment="Right" Margin="0,0,8,1" VerticalAlignment="Center" Width="7" Visibility="{TemplateBinding SortDescendentVisibility}" Cursor="Hand" />
                        <Path x:Name="SortAscendent" Grid.Column="1" Stretch="Fill" Fill="White" Data="F1 M 685,527L 682,521L 681,521L 678,527L 685,527 Z " Height="6" HorizontalAlignment="Right" Margin="0,0,8,1" VerticalAlignment="Center" Width="7" Visibility="{TemplateBinding SortAscendentVisibility}" Cursor="Hand" />
                        <Rectangle x:Name="Dragger" Opacity="0" Stretch="Fill" Fill="AliceBlue" Grid.Column="0" StrokeThickness="1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
    </Style>

    <Style TargetType="local:AgDataGridColumnGroupedHeader">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridColumnGroupedHeader">
                    <Grid Name="RootElement">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.5" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.25" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="1" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" To="0" />
                                        <DoubleAnimation Duration="00:00:00.001" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="Opacity" To="1" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border Grid.Column="0" Grid.ColumnSpan="2" Height="Auto" HorizontalAlignment="Stretch" 
								VerticalAlignment="Stretch" CornerRadius="3,3,3,3" Cursor="Hand">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#FFD7D7D7"/>
                                    <GradientStop Color="#FFF2F2F2" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>

                        <Border x:Name="MouseOverElement" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Opacity="0"
								Padding="0,0,0,0" CornerRadius="3,3,3,3" VerticalAlignment="Stretch">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#c2c2c2" Offset="0"/>
                                    <GradientStop Color="#dbdbdb" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>

                        <Border x:Name="PressedElement" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
								Opacity="0" Background="#FFc3c3c3" CornerRadius="2,2,2,2" />

                        <ContentControl x:Name="ContentElement" Grid.Column="0" Content="{TemplateBinding Content}" 
										  Margin="6,5,20,5" VerticalAlignment="Center">
                            <ContentControl.Foreground>
                                <SolidColorBrush x:Name="ContentForegroundBrush" Color="#FF464646" />
                            </ContentControl.Foreground>
                        </ContentControl>

                        <Path x:Name="SortDescendent" Grid.Column="1" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 678,521L 681,527L 682,527L 685,521L 678,521 Z " Height="6" HorizontalAlignment="Right" Margin="0,0,8,1" VerticalAlignment="Center" Width="7" Visibility="{TemplateBinding SortDescendentVisibility}" Cursor="Hand" />
                        <Path x:Name="SortAscendent" Grid.Column="1" Stretch="Fill" Fill="#FF6E6E6E" Data="F1 M 685,527L 682,521L 681,521L 678,527L 685,527 Z " Height="6" HorizontalAlignment="Right" Margin="0,0,8,1" VerticalAlignment="Center" Width="7" Visibility="{TemplateBinding SortAscendentVisibility}" Cursor="Hand" />

                        <Rectangle x:Name="Dragger" Opacity="0" Stretch="Fill" Fill="AliceBlue" Grid.Column="0" StrokeThickness="1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Margin" Value="12,16,0,16"/>
    </Style>

    <Style TargetType="local:AgDataGridCell">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridCell">
                    <Grid x:Name="RootElement">
                        <Border Background="{TemplateBinding Background}" CornerRadius="2,2,2,2" Margin="3,3,2,3"/>
                        <ContentControl x:Name="ContentElement"
								Content="{TemplateBinding Content}"
								ContentTemplate="{TemplateBinding ContentTemplate}"
								HorizontalAlignment="Stretch"
								VerticalAlignment="Center"
								HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
								Margin="6,4,6,4"
								Background="Transparent"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="#FF6E6E6E"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    </Style>

    <Style TargetType="local:AgDataGridTotalCell">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridTotalCell">
                    <Grid x:Name="RootElement" Margin="6,6,0,6">
                        <Rectangle x:Name="Clickable space" Fill="Transparent" Stroke="Transparent" Cursor="Hand"/>
                        <ContentPresenter Content="{TemplateBinding Content}" Grid.RowSpan="2" VerticalAlignment="Center" Cursor="Hand"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="White"/>
    </Style>

    <Style TargetType="local:AgDataGridTotalSelection">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridTotalSelection">
                    <Grid VerticalAlignment="Stretch" Width="100">
                        <Border Margin="4,4,0,0" x:Name="popup_shadow" Opacity="0.15" Background="#FF000000" CornerRadius="4,4,4,4"/>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,3,3" VerticalAlignment="Stretch" Width="Auto" Background="#FF404455" CornerRadius="3,3,3,3" Padding="1,1,1,1">
                            <Border Background="#FFFFFFFF" CornerRadius="2,2,2,2" Padding="12,12,12,12"/>
                        </Border>
                        <Button x:Name="TotalSelectionRect" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                        <StackPanel x:Name="CheckPanel" Margin="2,2,0,6">
                            <CheckBox x:Name="Sum" Margin="2,0,2,0" Content="Sum" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="Min" Margin="2,0,2,0" Content="Min" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="Max" Margin="2,0,2,0" Content="Max" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="Count" Margin="2,0,2,0" Content="Count" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="Average" Margin="2,0,2,0" Content="Average" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="Custom" Margin="2,0,2,0" Content="Custom" HorizontalAlignment="Left"/>
                            <CheckBox x:Name="None" local:dxElementStyles.StyleName="CheckBoxStyle" Margin="2,0,2,0" Content="None" HorizontalAlignment="Left"/>
                        </StackPanel>
                        <Grid Width="11" Height="11" Margin="0,2,5,0" HorizontalAlignment="Right" VerticalAlignment="Top">
                            <Grid.Resources>
                                <Style TargetType="Button" x:Name="CloseButtonStyle" >
                                    <Setter Property="Cursor" Value="Hand"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="Button">
                                                <Grid x:Name="RootElement">
                                                    <vsm:VisualStateManager.VisualStateGroups>
                                                        <vsm:VisualStateGroup x:Name="CommonStates">
                                                            <vsm:VisualState x:Name="Normal">
                                                                <Storyboard FillBehavior="HoldEnd">
                                                                    <DoubleAnimation Duration="00:00:00.1" Storyboard.TargetName="MouseOverState" Storyboard.TargetProperty="Opacity" To="0" />
                                                                    <DoubleAnimation Duration="00:00:00.1" Storyboard.TargetName="PressedState" Storyboard.TargetProperty="Opacity" To="0" />
                                                                </Storyboard>
                                                            </vsm:VisualState>
                                                            <vsm:VisualState x:Name="MouseOver">
                                                                <Storyboard FillBehavior="HoldEnd">
                                                                    <DoubleAnimation Duration="00:00:00.07" Storyboard.TargetName="MouseOverState" Storyboard.TargetProperty="Opacity" To="1" />
                                                                    <DoubleAnimation Duration="00:00:00" Storyboard.TargetName="PressedState" Storyboard.TargetProperty="Opacity" To="0" />
                                                                </Storyboard>
                                                            </vsm:VisualState>
                                                            <vsm:VisualState x:Name="Pressed">
                                                                <Storyboard FillBehavior="HoldEnd">
                                                                    <DoubleAnimation Duration="00:00:00" Storyboard.TargetName="PressedState" Storyboard.TargetProperty="Opacity" To="1" />
                                                                </Storyboard>
                                                            </vsm:VisualState>
                                                            <vsm:VisualState x:Name="Disabled"/>
                                                        </vsm:VisualStateGroup>
                                                    </vsm:VisualStateManager.VisualStateGroups>
                                                    <Ellipse Opacity="0" Stretch="Fill" Fill="Red"/>
                                                    <Path x:Name="NormalState" Stretch="Fill" Fill="#FF828798" Data="F1 M 623,489.5C 623,492.538 620.538,495 617.5,495C 614.462,495 612,492.538 612,489.5C 612,486.462 614.462,484 617.5,484C 620.538,484 623,486.462 623,489.5 Z M 621,488L 620,487L 617,490L 615,488L 614,489L 617,492L 621,488 Z "/>
                                                    <Path x:Name="MouseOverState" Opacity="0" Stretch="Fill" Fill="#FF222728" Data="F1 M 623,489.5C 623,492.538 620.538,495 617.5,495C 614.462,495 612,492.538 612,489.5C 612,486.462 614.462,484 617.5,484C 620.538,484 623,486.462 623,489.5 Z M 621,488L 620,487L 617,490L 615,488L 614,489L 617,492L 621,488 Z "/>
                                                    <Path x:Name="PressedState" Opacity="0" Stretch="Fill" Fill="#FF828798" Data="F1 M 623,489.5C 623,492.538 620.538,495 617.5,495C 614.462,495 612,492.538 612,489.5C 612,486.462 614.462,484 617.5,484C 620.538,484 623,486.462 623,489.5 Z M 621,488L 620,487L 617,490L 615,488L 614,489L 617,492L 621,488 Z "/>
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Grid.Resources>
                            <Button x:Name="CloseButton" Opacity="1" Style="{StaticResource CloseButtonStyle}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:AgDataGridGroupRow">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridGroupRow">
                    <Grid x:Name="RootElement" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.Background>
                            <SolidColorBrush Color="#FFE9E9E9"/>
                        </Grid.Background>

                        <Grid.Resources>
                            <SolidColorBrush x:Name="ButtonShapeColor" Color="#FF6E6E6E"/>
                            <Storyboard x:Name="Preview Story">
                                <DoubleAnimation x:Name="Preview Animation" Duration="0:0:0.500" Storyboard.TargetName="PreviewPresenterElement" Storyboard.TargetProperty="Height" />
                            </Storyboard>
                        </Grid.Resources>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="RowStates">
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="ContentForeground" Storyboard.TargetProperty="Color" 
												Duration="00:00:0.001" To="#FF464646"/>
                                        <ColorAnimation Storyboard.TargetName="ButtonShapeColor" Storyboard.TargetProperty="Color"  
												Duration="00:00:0.001" To="#FF6E6E6E"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="1"/>
                                        <ColorAnimation Storyboard.TargetName="ContentForeground" Storyboard.TargetProperty="Color" 
												Duration="00:00:0.001" To="#FF464646"/>
                                        <ColorAnimation Storyboard.TargetName="ButtonShapeColor" Storyboard.TargetProperty="Color"  
												Duration="00:00:0.001" To="#FF6E6E6E"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="1"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="ButtonShapeColor" Storyboard.TargetProperty="Color"  
												Duration="00:00:0.001" To="#FFFFFFFF"/>
                                        <ColorAnimation Storyboard.TargetName="ContentForeground" Storyboard.TargetProperty="Color"  
												Duration="00:00:0.001" To="#FFFFFFFF"/>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="1"/>
                                        <DoubleAnimation Storyboard.TargetName="FocusedElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="Opacity" 
												 Duration="00:00:0.001" To="0"/>
                                        <ColorAnimation Storyboard.TargetName="ButtonShapeColor" Storyboard.TargetProperty="Color"  
												Duration="00:00:0.001" To="#FF6E6E6E"/>
                                        <ColorAnimation Storyboard.TargetName="ContentForeground" Storyboard.TargetProperty="Color" 
												Duration="00:00:0.001" To="#FF464646"/>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="ExpandButtonStates">
                                <vsm:VisualState x:Name="Expanded">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.5" Storyboard.TargetName="ExpandButtonRotate" Storyboard.TargetProperty="Angle" To="90" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Collapsed">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="00:00:00.5" Storyboard.TargetName="ExpandButtonRotate" Storyboard.TargetProperty="Angle" To="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <Border x:Name="SelectedElement" Opacity="0" Grid.Row="0" Grid.ColumnSpan="3">
                            <Border.Background>
                                <SolidColorBrush Color="#FFC8DDF5" />
                            </Border.Background>
                        </Border>
                        <Border x:Name="FocusedElement" CornerRadius="3,3,3,3" Opacity="0" Grid.Row="0" Grid.ColumnSpan="3" Margin="1,1,1,1">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF9F9F9F"/>
                                    <GradientStop Color="#FF8C8C8C" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="MouseOverElement" Opacity="0" Grid.Row="0" Grid.ColumnSpan="3">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#FFDCDCDC" Offset="0"/>
                                    <GradientStop Color="#FFE2E2E2" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Button x:Name="ExpandButton" Grid.Column="1" Margin="10,0,5,0" RenderTransformOrigin="0.5, 0.5">
                            <Button.RenderTransform>
                                <RotateTransform x:Name="ExpandButtonRotate" Angle="0" />
                            </Button.RenderTransform>
                            <Button.Template>
                                <ControlTemplate>
                                    <Grid Width="11" Height="11"  >
                                        <Ellipse Cursor="Hand" Fill="Red" Opacity="0" />
                                        <Path Stretch="Fill" 
										    Data="F1 M 692,518L 692,529L 702,524L 702,523L 692,518 Z " HorizontalAlignment="Center" 
										    Margin="0,0,0,0" VerticalAlignment="Center" Cursor="Hand" Fill="{StaticResource ButtonShapeColor}">
                                        </Path>
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                        <ContentControl Content="{TemplateBinding ValueProperty}" Margin="2,4,3,4" VerticalAlignment="Center" Grid.Column="2">
                            <ContentControl.Foreground>
                                <SolidColorBrush x:Name="ContentForeground" Color="#FF464646" />
                            </ContentControl.Foreground>
                        </ContentControl>
                        <Border x:Name="IndentBlock" Margin="{TemplateBinding Padding}" Grid.Column="0" Width="0" Height="0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:AgDataGridTextBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridTextBox">
                    <Grid x:Name="RootElement">
                        <Border x:Name="ContentElement"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:AgDataGridDatePicker">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Background" Value="#FFFFFFFF" />
        <!--<Setter Property="Margin" Value="-1,2,0,-2"/>-->
        <Setter Property="SelectionBackground" Value="#FF444444"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AgDataGridDatePicker">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <!-- Main DatePicker Brushes -->
                            <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF" />

                            <!-- Button Template -->
                            <ControlTemplate x:Key="DropDownButtonTemplate" TargetType="Button">
                                <Grid>
                                    <vsm:VisualStateManager.VisualStateGroups>
                                        <vsm:VisualStateGroup x:Name="CommonStates">
                                            <vsm:VisualStateGroup.Transitions>
                                                <vsm:VisualTransition GeneratedDuration="0" />
                                                <vsm:VisualTransition To="MouseOver" GeneratedDuration="0:0:0.1" />
                                                <vsm:VisualTransition To="Pressed" GeneratedDuration="0:0:0.1" />
                                            </vsm:VisualStateGroup.Transitions>
                                            <vsm:VisualState x:Name="Normal" />
                                            <vsm:VisualState x:Name="MouseOver">
                                                <Storyboard>
                                                    <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#FF448DCA"/>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </vsm:VisualState>
                                            <vsm:VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#FF448DCA"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                        <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#EAFFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                    <ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                                        <SplineColorKeyFrame KeyTime="0" Value="#F4FFFFFF"/>
                                                    </ColorAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </vsm:VisualState>
                                            <vsm:VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                        <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </vsm:VisualState>
                                        </vsm:VisualStateGroup>
                                    </vsm:VisualStateManager.VisualStateGroups>

                                    <!--Start UI-->
                                    <Grid Height="18" Width="19" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Background="#11FFFFFF">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="23*"/>
                                            <RowDefinition Height="19*"/>
                                            <RowDefinition Height="19*"/>
                                            <RowDefinition Height="19*"/>
                                        </Grid.RowDefinitions>
                                        <Border Margin="-1" Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" BorderThickness="1" BorderBrush="#FF45D6FA" Opacity="0" CornerRadius="0,0,1,1" x:Name="Highlight"/>
                                        <Border x:Name="Background" Margin="0,-1,0,0" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" BorderThickness="1" BorderBrush="#FFFFFFFF" Opacity="1" CornerRadius=".5" Background="#FF1F3B53"/>
                                        <Border x:Name="BackgroundGradient" Margin="0,-1,0,0" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" BorderThickness="1" BorderBrush="#BF000000" Opacity="1" CornerRadius=".5">
                                            <Border.Background>
                                                <LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
                                                    <GradientStop Color="#FFFFFFFF" Offset="0" />
                                                    <GradientStop Color="#F9FFFFFF" Offset="0.375" />
                                                    <GradientStop Color="#E5FFFFFF" Offset="0.625" />
                                                    <GradientStop Color="#C6FFFFFF" Offset="1" />
                                                </LinearGradientBrush>
                                            </Border.Background>
                                        </Border>
                                        <Rectangle Grid.ColumnSpan="4" Grid.RowSpan="1" StrokeThickness="1">
                                            <Rectangle.Stroke>
                                                <LinearGradientBrush EndPoint="0.48,-1" StartPoint="0.48,1.25">
                                                    <GradientStop Color="#FF494949"/>
                                                    <GradientStop Color="#FF9F9F9F" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Stroke>
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint="0.3,-1.1" StartPoint="0.46,1.6">
                                                    <GradientStop Color="#FF4084BD"/>
                                                    <GradientStop Color="#FFAFCFEA" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <Path HorizontalAlignment="Center" Margin="4,3,4,3" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Grid.Column="0" Grid.Row="1" Fill="#FF2F2F2F" Stretch="Fill" Data="M11.426758,8.4305077 L11.749023,8.4305077 L11.749023,16.331387 L10.674805,16.331387 L10.674805,10.299648 L9.0742188,11.298672 L9.0742188,10.294277 C9.4788408,10.090176 9.9094238,9.8090878 10.365967,9.4510155 C10.82251,9.0929432 11.176106,8.7527733 11.426758,8.4305077 z M14.65086,8.4305077 L18.566387,8.4305077 L18.566387,9.3435936 L15.671368,9.3435936 L15.671368,11.255703 C15.936341,11.058764 16.27293,10.960293 16.681133,10.960293 C17.411602,10.960293 17.969301,11.178717 18.354229,11.615566 C18.739157,12.052416 18.931622,12.673672 18.931622,13.479336 C18.931622,15.452317 18.052553,16.438808 16.294415,16.438808 C15.560365,16.438808 14.951641,16.234707 14.468243,15.826504 L14.881817,14.929531 C15.368796,15.326992 15.837872,15.525723 16.289043,15.525723 C17.298809,15.525723 17.803692,14.895514 17.803692,13.635098 C17.803692,12.460618 17.305971,11.873379 16.310528,11.873379 C15.83071,11.873379 15.399232,12.079271 15.016094,12.491055 L14.65086,12.238613 z" Grid.ColumnSpan="4" Grid.RowSpan="3"/>
                                        <Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#FFFFFFFF" StrokeThickness="0" Grid.ColumnSpan="4" Width="3" Height="3"/>
                                        <Border Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" BorderThickness="1" BorderBrush="#B2FFFFFF" Opacity="0" CornerRadius="0,0,.5,.5" x:Name="DisabledVisual"/>
                                    </Grid>
                                    <!--End UI-->
                                </Grid>
                            </ControlTemplate>
                        </Grid.Resources>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <primitives:DatePickerTextBox x:Name="TextBox" SelectionBackground="{TemplateBinding SelectionBackground}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Column="0" />
                        <Button x:Name="Button" Template="{StaticResource DropDownButtonTemplate}" Grid.Column="1" Width="20" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="3,0,0,1"/>
                        <Grid x:Name="DisabledVisual" Opacity="0" IsHitTestVisible="False" Grid.ColumnSpan="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Rectangle RadiusX="1" RadiusY="1" Fill="#A5FFFFFF" Grid.Column="0"/>
                            <Rectangle RadiusX="1" RadiusY="1" Fill="#A5FFFFFF" Grid.Column="1" Height="18" Width="19" Margin="3,0,3,0" />
                        </Grid>
                        <Popup x:Name="Popup"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Name="DatePickerTextBoxTemplate" TargetType="primitives:DatePickerTextBox">
        <Grid x:Name="Root" >
            <Grid.Resources>
                <SolidColorBrush x:Key="WatermarkBrush" Color="#FFAAAAAA"/>
            </Grid.Resources>
            <vsm:VisualStateManager.VisualStateGroups>
                <vsm:VisualStateGroup x:Name="WatermarkStates">
                    <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition GeneratedDuration="0" />
                    </vsm:VisualStateGroup.Transitions>
                    <vsm:VisualState x:Name="Unwatermarked" />
                    <vsm:VisualState x:Name="Watermarked">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                            <DoubleAnimation Storyboard.TargetName="Watermark" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                        </Storyboard>
                    </vsm:VisualState>
                </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Border x:Name="Border" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1" Opacity="1" BorderBrush="{TemplateBinding BorderBrush}">
                <Grid x:Name="WatermarkContent" Background="{TemplateBinding Background}">
                    <Border x:Name="ContentElement" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                    <ContentControl
                      x:Name="Watermark"
                      Opacity="0"
                      IsTabStop="False"
                      IsHitTestVisible="False"
                      Content="{TemplateBinding Watermark}"
                      Foreground="{StaticResource WatermarkBrush}"
                      Background="{TemplateBinding Background}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                      HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Grid>
            </Border>
        </Grid>
    </ControlTemplate>

</ResourceDictionary>
